package com.qifenqian.turbot.module.adapter.order

import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.qifenqian.turbot.R
import com.qifenqian.turbot.config.TurbotEnum
import com.qifenqian.turbot.module.entity.response.order.OrderTableEntity
import kotlinx.android.synthetic.main.item_order_table.view.*

/**
 * @author H
 * @createTime 2019/1/10 09:30
 * @description
 * @see
 * @since
 */
class OrderTableAdapter(data: List<OrderTableEntity>?) : BaseQuickAdapter<OrderTableEntity, BaseViewHolder>(R.layout.item_order_table, data) {

    override fun convert(helper: BaseViewHolder, item: OrderTableEntity) {
        val view = helper.itemView
        view.tv_item_order_table_name.text = item.tableNo
        view.tv_item_order_table_people_count.text = "${item.minNumberOfPeople}-${item.maxNumberOfPeople}人"
        view.iv_item_order_table_balcony.visibility = if (item.tableType == TurbotEnum.TYPE_BALCONY.type) View.VISIBLE else View.INVISIBLE
        view.ly_item_main_order_table.setBackgroundResource(if (item.isUsing) R.drawable.bg_rectangle_red else R.drawable.bg_rectangle_line)
        view.tv_item_order_table_name.setTextColor(mContext.resources.getColor(if (item.isUsing) R.color.white else R.color.gray_666666))
        view.tv_item_order_table_people_count.setTextColor(mContext.resources.getColor(if (item.isUsing) R.color.white else R.color.gray_666666))
    }
}
